Defining a For Loop Function
The For Loop function can be used when you need to maintain an iterator value, for example, when parsing text or iterating through a dictionary's keys and getting their values.
The For Loop function can also be used to iterate through a list and to work with list values. When iterating through a list, the iteration is one-based and not zero-based, as in most computer languages. Therefore, to iterate through all the members of a list, the condition must use a less than or equal to (<=) operator instead of a less than (<) operator.
Use no more than four nested IF/For/For Each statements.
To define a For Loop function:
1. | Click Insert Instruction to display the following drop-down menu: |
Select For to display the following action statement:
2. | Click the <Iterator> link to display an Assignment Tool and specify the name of the iterator. |
3. | Click the <Select Value> link in the middle to display an Assignment Tool and specify the starting value for the iterator. This value must be a numeric constant, a numeric property, or a method that returns a numeric value. |
4. | Click the <…> link to specify when this loop is started/stopped. This opens a Boolean Statement Editor in which you specify the applicable break condition. For example, iterating when the iterator is <= the length of the iterated list, or when a certain business entity Boolean value is false (in this case, the For Loop acts as a While Loop). |
5. | Click the corresponding <Select Value> link to display an Assignment Tool and specify the increment to be used by the iterator. You can increment by a numeric constant or by a method that returns a number. |
6. | Define the inner statement of the For Loop, which is the statement inside the brackets. You can add any type of expression for this statement. |
You can also use the iterator in an inner statement. The example below shows the use of the iterator to iterate through the values of a list: